package cn.buaa.myweixin.adapter;

import java.util.List;

import cn.buaa.myweixin.R;
import cn.buaa.myweixin.entity.User;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class FriendsListAdapter extends BaseAdapter{
	
	private Context ctx;
	private List<User> list;
	
	public FriendsListAdapter(Context ctx,List<User> list){
		this.ctx = ctx;
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		LinearLayout li = null;
		if(convertView==null){
			li = (LinearLayout) LinearLayout.inflate(ctx, R.layout.friendrow, null);
		}else{
			li = (LinearLayout) convertView;
		}
		TextView tv = (TextView) li.findViewById(R.id.textname);
		tv.setText(list.get(position).getName());
		return li;
	}

}









